package com.migu.rbac.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * 设置RestTemplate配置项
 */
@Configuration
public class RestRbacTemplateConfig {

    /**
     * 设置连接超时时间和获取数据超时时间
     * @return
     */
    @Bean
    public RestTemplate customRestTemplate(){
        HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
        httpRequestFactory.setConnectionRequestTimeout(500);
        httpRequestFactory.setConnectTimeout(500);
        httpRequestFactory.setReadTimeout(500);

        return new RestTemplate(httpRequestFactory);
    }
}
